package com.zqx.facade.childsystem;

import lombok.extern.slf4j.Slf4j;

import java.io.FileInputStream;
import java.io.FileNotFoundException;

/**
 * description: 子系统类
 * @author zqx
 * @date 2018/09/04
 */
@Slf4j
public class FileReader {

    public String read(String fileNameSrc)
    {
        StringBuffer stringBuffer = new StringBuffer();
        try {
            FileInputStream fileInputStream = new FileInputStream(fileNameSrc);
            int data;
            while((data = fileInputStream.read())!=-1)
            {
                stringBuffer = stringBuffer.append((char)data);
            }
            fileInputStream.close();
            System.out.println("子文件字符串为"+stringBuffer.toString());
            //log.info("子文件字符串为,{}",stringBuffer.toString());
        } catch (FileNotFoundException e) {
            //log.info("文件不存在");

            e.printStackTrace();
        }catch (Exception e) {
            System.out.println("文件操作错误");
            //log.info("文件操作错误");
            e.printStackTrace();
        }
        return stringBuffer.toString();
    }
}
